package com.sg.bars.server.kernel.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sg.bars.client.kernel.action.ActionException;

public class ActionQueryRunnerImpl implements ActionQueryRunner {
	private static final long serialVersionUID = -3360454897260222444L;

	protected final Logger logger = LoggerFactory.getLogger(getClass());
	
	private DataServiceCore dataServiceCore;

	@Override
	public Object doActionQuery(AbstractActionQuery actionQuery) throws ActionException {
			
		switch (actionQuery.getTransactionalConfig()) {
		case TRANSACTIONAL_REQUIRED:
			return getDataServiceCore().doActionQueryTransactionalRequired(actionQuery, this);
		case TRANSACTIONAL_REQUIRED_READONLY:
			return getDataServiceCore().doActionQueryTransactionalRequiredReadOnly(actionQuery, this);
		case UNTRANSACTIONAL:
			return getDataServiceCore().doActionQueryUnTransactional(actionQuery, this);
		default:
			throw new IllegalArgumentException("Unknown Transactional argument");
		}
	}

	public DataServiceCore getDataServiceCore() {
		return dataServiceCore;
	}

	public void setDataServiceCore(DataServiceCore dataServiceCore) {
		this.dataServiceCore = dataServiceCore;
	}

}
